package demo06234;
    // 银行卡支付实现
    public class BankCardPayment implements Payment {
        private double balance;
        private String cardNumber;

        public BankCardPayment(double balance, String cardNumber) {
            this.balance = balance;
            this.cardNumber = cardNumber;
        }

        @Override
        public boolean pay(double amount) {
            if (balance >= amount) {
                balance -= amount;
                System.out.printf("银行卡(%s)支付成功: %.2f元\n", cardNumber, amount);
                return true;
            } else {
                System.out.println("银行卡余额不足，支付失败");
                return false;
            }
        }

        @Override
        public double getBalance() {
            return balance;
        }

        @Override
        public String getPaymentName() {
            return "银行卡支付";
        }
    }

